home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / DIACHECK.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  2.5 KB  |  118 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // DialogClass
  8. // DiaCheckBox
  9. //
  10.  
  11. #include "fli.h"
  12. #include "elements.h"
  13. #include "colors.h"
  14.  
  15. #ifdef __BCPLUSPLUS__
  16. #pragma hdrstop
  17. #endif
  18.  
  19. #include <string.h>
  20.  
  21. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  22. //
  23. // DiaCheckBox()
  24. //
  25. // Constructor for DiaCheckBox
  26. //
  27. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  28.  
  29. DiaCheckBox::DiaCheckBox(int _X,int _Y,int &_Checked,char *_CheckText,int Quick) :
  30.   Checked(_Checked),
  31.   CheckText(_CheckText)
  32. {
  33.   X=_X;
  34.   Y=_Y;
  35.   QuickKey=Quick;
  36.   Width=strlen(_CheckText)+6-((strchr(_CheckText,'~'))?1:0);
  37.   Height=1;
  38. }
  39.  
  40. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  41. //
  42. // Show()
  43. //
  44. // Show the check box
  45. //
  46. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  47.  
  48. void DiaCheckBox::Show()
  49. {
  50.   MouseHide();
  51.  
  52.   int Avail=(Available()==CompleteEvent);
  53.  
  54.   (*Blaze) (X,Y)
  55.     << ((Avail)?Colors.CheckText:Colors.DiaDeadLocator)
  56.     << " ["
  57.     << ((Avail)?Colors.CheckMark:Colors.DiaDeadLocator)
  58.     << ((Checked)?'X':' ')
  59.     << ((Avail)?Colors.CheckText:Colors.DiaDeadLocator)
  60.     << "] ";
  61.  
  62.   Blaze->QuickDisplay(X+5,Y,
  63.     (Avail)?Colors.CheckQuickKey:Colors.DiaDeadLocator,
  64.     (Avail)?Colors.CheckText:Colors.DiaDeadLocator,CheckText);
  65.  
  66.   (*Blaze) << ' ';
  67.  
  68.   MouseShow();
  69. }
  70.  
  71. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  72. //
  73. // HighLight()
  74. //
  75. // Highlight the check box
  76. //
  77. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  78.  
  79. void DiaCheckBox::HighLight()
  80. {
  81.   MouseHide();
  82.  
  83.   (*Blaze) (X,Y)
  84.     << Colors.CheckHiLite
  85.     << " ["
  86.     << ((Checked)?'X':' ')
  87.     << "] ";
  88.  
  89.   Blaze->QuickDisplay(X+5,Y,Colors.CheckHiLite,Colors.CheckHiLite,CheckText);
  90.  
  91.   (*Blaze) << ' ';
  92.  
  93.   Blaze->WindowGotoXY(X+2,Y);
  94.   MouseShow();
  95. }
  96.  
  97. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  98. //
  99. // EventHandler()
  100. //
  101. // Handles the events
  102. //
  103. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  104.  
  105. int DiaCheckBox::EventHandler(int Event)
  106. {
  107.   if (Event==' ' ||
  108.     (Event==ValidatedMousedEvent && MouseEvent&MouseLeftButtonRelease) ||
  109.     Event==QuickKey)
  110.   {
  111.     Checked=(Checked)?0:1;
  112.     HighLight();
  113.     return CompleteEvent;
  114.   }
  115.  
  116.   return Event;
  117. }
  118.